package io.renren.modules.information.controller;

import io.renren.common.utils.R;
import io.renren.modules.information.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

/**
 * 数据采集
 */
@RequestMapping("information")
@RestController
public class InformationController {

    @Autowired
    private InformationService informationService;

    /**
     * 数据采集模块
     * 查询每个设备的最新一条数据
     */
    @RequestMapping("getList")
    public R getList(@RequestParam Map<String, Object> params) {
        return R.ok(informationService.getList(params));
    }

    /**
     * 数据采集模块
     * 查询单个设备的数据集合
     */
    @RequestMapping("get")
    public R getPage(@RequestParam Map<String, Object> params) {
        return informationService.getPage(params);
    }

    /**
     * 数据采集模块
     * 查询单个设备的数据集合
     * 获取折线图数据格式
     */
    @RequestMapping("getLineChart")
    public R getLineChart(String deviceId) {
        return informationService.getLineChart(deviceId);
    }

    /**
     * 数据报表模块-采集数据
     */
    @RequestMapping("getDataList")
    public R getDataList(@RequestParam Map<String, Object> params) {
        return R.ok(informationService.getDataList(params));
    }

    /**
     * 数据报表模块-生成报告
     */
    @RequestMapping("addReport")
    public R addReport(@RequestParam(value = "spaceId", required = false) Integer spaceId,
                            @RequestParam(value = "startTime", required = false) String startTime,
                            @RequestParam(value = "endTime", required = false) String endTime) {
        return informationService.addReport(spaceId, startTime, endTime);
    }

    /**
     * 数据报表模块-报告列表
     *
     */
    @RequestMapping("getReportList")
    public R getReportList(@RequestParam Map<String, Object> params) {
        return R.ok(informationService.getReportList(params));
    }

    /**
     *  数据报表模块-报告列表 删除
     */
    @RequestMapping("deleteReport")
    public R deleteReport(Integer id) {
        return informationService.deleteReport(id);
    }


    /**
     * 数据报表模块-报告列表
     *
     */
    @RequestMapping("getReport")
    public R getReport(@RequestParam("id") Integer id) {
        return R.ok(informationService.getReport(id));
    }


    /**
     * app端数据列表查询
     *
     */
    @RequestMapping("getEnvironmentList")
    public R getEnvironmentList(@RequestParam Map<String, Object> params) {
        return R.ok(informationService.getEnvironmentList(params));
    }

    /**
     * app端环境指标及评价
     *
     */
    @RequestMapping("getEnvironmentIndex")
    public R get() {
        return R.ok(informationService.getEnvironmentIndex());
    }



}
